package com.muh.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class RabbitMQUtil {
    private static final String HOST_NAME = "39.104.74.101";
    private static final int PORT = 5672;
    private static final String USER_NAME = "admin";
    private static final String PASSWORD = "admin";
    private static final String VIRTUAL_HOST = "/mirror";//虚拟机

//    private static final String EXCHANGE_NAME = "callbackExchange";
//    private static final String ALTER_EXCHANGE_NAME = "alterExchange";
    public static final String QUEUE_HELLO = "hello";
    public static final String QUEUE_WORK = "work";
    public static final String QUEUE_PUBLISH = "publish";

    private RabbitMQUtil(String[] args) {}
    public static Connection getConnection() throws IOException, TimeoutException {
        //建立连接Factory
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost(HOST_NAME);
        factory.setPort(PORT);
        factory.setUsername(USER_NAME);
        factory.setPassword(PASSWORD);
        factory.setVirtualHost(VIRTUAL_HOST);
        //建立连接
        Connection connection = factory.newConnection();
        return connection;
    }
}
